package com.example.su_shi_tan_mine.child

import android.view.View
import androidx.appcompat.widget.Toolbar
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.example.su_shi_tan_bas_lib.base.BaseFragmentEx
import com.example.su_shi_tan_bas_lib.base.BaseLazyDataBindingFragment
import com.example.su_shi_tan_bas_lib.networking.RestClient
import com.example.su_shi_tan_core.arouter.MineARouter
import com.example.su_shi_tan_core.extentions.startNavigation
import com.example.su_shi_tan_core.signOut
import com.example.su_shi_tan_mine.R
import com.example.su_shi_tan_mine.arouter.SubPageARouter
import com.example.su_shi_tan_mine.databinding.SecureCenterFragmentBinding

@Route(path = MineARouter.SECURE_CENTER)
class SecureCenterFragment:BaseLazyDataBindingFragment<SecureCenterFragmentBinding>(),
    View.OnClickListener {

    override fun layoutId()= R.layout.secure_center_fragment

    override fun lazyInit() {

    }

    override fun initView(view: View) {
        val mToolbar: Toolbar = view.findViewById(R.id.mToolbar)
        mToolbar.title = "安全中心"
        mToolbar.setNavigationOnClickListener { onBackPressedSupport() }
        viewBinder.onViewClick = this
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.reSettingPassword -> {
                ARouter.getInstance()
                    .build(SubPageARouter.ReSettingPassWord)
                    .startNavigation(this)

            }
            R.id.aboutUs -> {
                ARouter.getInstance()
                    .build(SubPageARouter.AboutUs)
                    .startNavigation(this)
//                start(AboutUsFragment.newInstance())
            }
            R.id.sign_out -> {

                signOut()

                RestClient.builder()
                    .url(R.string.api_logout)
                    .build()
                    .get()

            }
        }
    }


}